<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }

      html,
      body,
      #mask {
        width: 100%;
        height: 100%;
      }

      #mask {
        background-color: #c9c9c9;
        position: relative;
      }

      #mask .center {
        position: absolute;
        background-color: #fff;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        padding: 10px;
      }

      #mask .center > img {
        display: block;
        width: 700px;
        height: 458px;
      }

      #mask .center a {
        text-decoration: none;
        width: 45px;
        height: 100px;
        position: absolute;
        top: 179px;
        vertical-align: middle;
        opacity: 0.5;
      }
      #mask .center a :hover {
        opacity: 0.8;
      }

      #mask .center .left {
        left: 15px;
        text-align: left;
        padding-right: 10px;
        border-top-right-radius: 10px;
        border-bottom-right-radius: 10px;
      }

      #mask .center .right {
        right: 15px;
        text-align: right;
        padding-left: 10px;
        border-top-left-radius: 10px;
        border-bottom-left-radius: 10px;
      }
    </style>
  </head>
  <body>
    <div id="mask">
      <div class="center">
        <img :src="imgList[index]" alt="" />
        <a
          href="javascript:void(0)"
          @click="prev"
          class="left"
          v-show="index>0"
        >
          <img src="../images/prev.png" alt="" />
        </a>
        <a
          href="javascript:void(0)"
          @click="next"
          class="right"
          v-show="index<imgList.length-1"
        >
          <img src="../images/next.png" alt="" />
        </a>
      </div>
    </div>

    <script src="../lib/vue.js"></script>

    <script>
      let vm = new Vue({
        el: '#mask',
        data: {
          imgList: [
            '../images/100.jpg',
            '../images/200.jpg',
            '../images/300.jpg',
            '../images/400.jpg',
            '../images/500.jpg',
          ],
          index: 0,
        },
        methods: {
          prev: function () {
            this.index--
          },
          next: function () {
            this.index++
          },
        },
      })
    </script>
  </body>
</html>
